;
//传值方法
var upload = {

    error:function ( msg ) {

        alert(msg);

    },
    success:function ( username ) {

        var pele = $('#names');
        //移除输入框
        pele.find('target_name').remove();
        var html = '<p  data-name="'+username+'">用户名:'+username+'</p>';
        pele.html(html);

    }


};

//jQuery事件绑定
var img_ops_set = {
    init:function () {

        this.eventBind();

    },
    eventBind:function () {

        var that = this;
        //图片操作
        var img = $('.target_img');
        //双击图片进行隐藏
        img.dblclick(function () {
           $(this).find('img').remove();

           var html = '单击恢复';

            $(this).html(html);
        });

        //单击恢复图片
        img.click( function ( ) {

            var src = $(this).find('img').attr('src');

            if( src ==undefined ){

                var html = '双击隐藏<img class="img" src="/static/img/1.jpg" >'

                $(this).html( html );
            }

        });

        ////双击事件恢复input输入框
        $('#names').dblclick(function () {

            var name = $(this).find('p').data('name');

            if ( name == undefined ){


            }else{

                var html = '用户名:<input name="username" type="text" class="target_name" value="'+name+'">';

                $(this).html(html);


            }


        });

        $('.target_input .target_name input[name=username]').change(function () {

            $(this).submit();

        })
        
    }
};

$(document).ready(function () {
   img_ops_set.init();
});